package com.qf.blog.config;

import com.qf.blog.interceptor.IsLoginInterceptor;
import com.qf.blog.interceptor.LoginUserInfoInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMVCConfig implements WebMvcConfigurer {
    @Autowired
    private LoginUserInfoInterceptor loginUserInfoInterceptor;

    @Autowired
    private IsLoginInterceptor isLoginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginUserInfoInterceptor).addPathPatterns("/**");
        registry.addInterceptor(isLoginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/","/login","/register","/activateAccount","/*/*.html",
                        "/js/**","/css/**","/img/**","/editor-md/**","/editor-md-upload/**","/error");
    }
}
